let historyStack = [];

function listenHistory() {
	window.addEventListener(
		"hashchange",
		() => {
			let hash = location.hash.slice(1);
			let index = historyStack.findIndex(item => hash === item);
			if (index === -1) {
				historyStack.push(hash);
			} else {
				historyStack = historyStack.slice(0, index + 1);
			}
		},
		false
	);
}

function canCloseH5() {
	return historyStack.length <= 2;
}
export { listenHistory, canCloseH5 };
